﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dados.DSMPTUDOTableAdapters;

namespace Dados
{
    public class Software_De_Reproducao_DAL
    {
        static T_SOFTWARE_DE_REPRODUCAOTableAdapter softwareTA = new T_SOFTWARE_DE_REPRODUCAOTableAdapter();
       
        public static DSMPTUDO.T_SOFTWARE_DE_REPRODUCAODataTable ConsultaTodos()
        {
           try
           {
                return softwareTA.GetData();
                
           }
            catch (Exception ex) 
            {
                throw new Exception(ex.Message);
         }
                       
        }

        public static DSMPTUDO.T_SOFTWARE_DE_REPRODUCAODataTable ConsultaPorCodigo(int codigo) 
        {
            try
            {
                return softwareTA.GetSoftwareDeReproducaoPorCodigo(codigo);
               
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message); 
            }
        }

        public static bool Insere(string nome, string fabricante, int tipo)
        {
           try
            {
                return (softwareTA.Insert(nome,fabricante,tipo) ==1);
                  
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public static bool Atualiza(string nome,string fabricante, int tipo,int codigo)
        {
            try
            {
                return (softwareTA.Update(nome,fabricante,tipo,codigo,codigo) == 1);

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public static bool Remove(int codigo)
        {
            try
            {
                return (softwareTA.Delete(codigo) ==1);
                     
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }   
        }
    }
    }

